import sys
import psutil
import time


def show_process_status(pid):
    p = psutil.Process(pid)
    print("进程名: ", p.name())
    print("进程状态: ", p.status())
    print("进程创建时间: ", p.create_time())
    print("进程运行时间: ", p.cpu_times())
    print("进程内存使用情况: ", p.memory_info())
    print("进程IO使用情况: ", p.io_counters())
    print("进程开启的线程数: ", p.num_threads())
    print("进程开启的文件数: ", p.num_fds())


if __name__ == "__main__":
    if len(sys.argv) != 2:
        pid = int(input("请输入进程pid: "))
    else:
        pid = int(sys.argv[1])
    show_process_status(pid)
